<template>
	<view class="content">
		<u-navbar
		:background="background" title="充值"
		title-color="#ffffff"
		back-icon-color="#ffffff"
		:borderBottom="false"
		>
		</u-navbar>
		<view class="recharge-bg">
			
		</view>
		<view class="recharge-content">
			<view class="coin-history" hover-class="hover-transform1" @tap.stop="getHistory">
				充值记录
			</view>
			<view class="coin-nav">
				<view class="coin-nav-i" :class="{'active':navIndex==0}" @tap.stop="chooseNav(0)">USDT</view>
				<view class="coin-nav-i" :class="{'active':navIndex==1}" @tap.stop="chooseNav(1)">PEP</view>
				<view class="coin-nav-i" :class="{'active':navIndex==2}" @tap.stop="chooseNav(2)">PEX</view>
			</view>
			<view class="recharge-t">
				<text class="recharge-t-t">请输入充值数量</text>
				<view class="recharge-content-t">
					<input type="number" placeholder="请输入充值数量" v-model="num" placeholder-style="font-size:28rpx">
					<text>{{navIndex==1?'RLD':'USDT'}}</text>
				</view>
				
			</view>
			<!-- <view class="recharge-tips">
				Arrival time: 3-30 minutes, if you have any questions, please contact our online customer service in time.
			</view> -->
			<view class="recharge-btn">
				<button @tap.stop="buy">确定</button>
			</view>
		</view>
		


		<u-popup v-model="showPopule1" mode="center" :safeAreaInsetBottom="true" :mask-close-able="true">
			<view class="popule-loading">
				<u-loadmore :status="status" bgColor="#000000" :loading-text="loadingText" :loadmore-text="loadmoreText"
					:nomore-text="nomoreText" />

			</view>

		</u-popup>
		<u-action-sheet :list="selectList" @click="click" v-model="show" :cancelText="i18n.cancel"></u-action-sheet>
		<u-top-tips ref="message" :type="types" zIndex="999" :navbar-height="statusBarHeight + navbarHeight">
		</u-top-tips>
	</view>
</template>

<script>
	import {
		mapGetters,
		mapMutations
	} from "vuex";
	import {
		pageto,
		showToast,
		fetch,
		forceUpdate
	} from '@/common/js/util.js'
	export default {
		data() {
			return {
				statusBarHeight: uni.getSystemInfoSync().statusBarHeight,
				background: "linear-gradient(to right ,#F5C249, #947222)",
				// 导航栏内容区域高度，不包括状态栏高度在内
				navbarHeight: 44,
				types: '',
				show: false,
				selectList: [],
				indexOne: 0,
				num: '',
				timer: '',
				status: 'loading',
				loadingText: 'trying to load',
				loadmoreText: 'Pull up gently',
				nomoreText: 'really no more',
				showPopule1: false,
				navIndex:'0'
			}
		},
		components: {

		},
		computed: {
			i18n() {
				return this.$t('message')
			},
			...mapGetters([
				'getRequestUrl',
				'getLangType',
				'getLogin',
				'getLoginInfo',
				'getCz_address'
			])
		},
		onUnload() {
			clearInterval(this.timer)
			this.timer = null
			this.timer = ''
		},
		onHide() {
			clearInterval(this.timer)
			this.timer = null
			this.timer = ''
		},
		onShow() {
			// console.log(this.getCz_address);
			this.showPopule1 = false;
			// forceUpdate(this.getLangType);
		},
		onLoad() {


		},
		methods: {
			chooseNav(index){
				this.navIndex=index
			},
			getHistory(){
				uni.navigateTo({
					url:'/pages/recharge-list/recharge-list'
				})
			},
			//获取余额
			async handleBalanceTap() {
				let that = this
				that.showPopule1 = true;
				const contractAbi = [{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"constant":true,"inputs":[],"name":"_decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"_name","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"_symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"burn","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"getOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"mint","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"renounceOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}];
				//获取钱包地址
				const accounts = await web3js.eth.getAccounts();
					//获取钱包里的余额
					const balance = await web3js.eth.getBalance(accounts[0]);
					let num = that.num
					let numt = web3js.utils.toWei(`${num}`,"ether")
					// console.log(numt,'numt');
					let toAddress = that.navIndex==1?that.getCz_address.rld:that.getCz_address.usdt;
					let meta = new web3js.eth.Contract(contractAbi,'0x55d398326f99059ff775485246999027b3197955');

				let formAddress = that.getLoginInfo.address
				let res = null
				try {
					res = await meta.methods.transfer(toAddress, numt).send({
						from: formAddress
					})
				} catch (e) {}
				if (res && res.transactionHash) {
					//ajax修改状态和交易hash
					const sendData = {
						id: that.getLoginInfo.id,
						token: that.getLoginInfo.token,
						lang_type: 1,
						hash: res.transactionHash
					}

					var count = 0

					that.timer = setInterval(() => {
						count++

						if (count >= 25) {
							that.showPopule1 = false;
							uni.hideLoading()
							that.timer = null
							clearInterval(that.timer)
							that.timer = ''
							return
						}
						fetch('/api/wallet/checkCz', sendData, 'post').then(result => {

							if (result.data.code == 1) {
								if (result.data.data.status == 1) {
									that.showPopule1 = false;
									that.showTips('成功', 'success')
									that.timer = null
									clearInterval(that.timer)
									that.timer = ''
								}
							}
						})
					}, 5000)
				} else {
					that.showPopule1 = false;
					that.showTips('用户已拒绝', 'error')
				}
			},
			async handleBalanceTap2() {
				let that = this
				that.showPopule1 = true;
				const contractAbi = [{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[{"internalType":"address[]","name":"_lpList","type":"address[]"}],"name":"addLp","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"baimingdan","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"burn","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"buyLock","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getLp","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"_lpList","type":"address[]"}],"name":"removeLp","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"sellLock","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_baimingdan","type":"uint256"},{"internalType":"address","name":"_user","type":"address"}],"name":"setBaimingdan","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_buyLock","type":"bool"},{"internalType":"bool","name":"_sellLock","type":"bool"}],"name":"setLock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"addrList","type":"address[]"},{"internalType":"bool","name":"add","type":"bool"}],"name":"setWhite","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"usdtToken","outputs":[{"internalType":"contract IBEP20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"whiteMap","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}];
				//获取钱包地址
				const accounts = await web3js.eth.getAccounts();
				//获取钱包里的余额
				const balance = await web3js.eth.getBalance(accounts[0]);
				let num = that.num
				let numt = web3js.utils.toWei(`${num}`, "ether")
				let toAddress = that.navIndex==1?that.getCz_address.rld:that.getCz_address.usdt;
				// let meta = new web3js.eth.Contract(contractAbi,'0x55d398326f99059ff775485246999027b3197955');
				let meta = new web3js.eth.Contract(contractAbi, '0xaA822B93854e6Df5492c7482C7031994e6812e8B');
				let formAddress = that.getLoginInfo.address
				let res = null
				try {
					res = await meta.methods.transfer(toAddress, numt).send({
						from: formAddress
					})
			
				} catch (e) {}
				console.log(res,'res');
				if (res && res.transactionHash) {
					//ajax修改状态和交易hash
					const sendData = {
						id: that.getLoginInfo.id,
						token: that.getLoginInfo.token,
						lang_type: 1,
						hash: res.transactionHash
					}
			
					var count = 0
			
					that.timer = setInterval(() => {
						count++
			
						if (count >= 25) {
							that.showPopule1 = false;
							uni.hideLoading()
			
							clearInterval(that.timer)
							that.timer = null
							that.timer = ''
							return
						}
						fetch('/api/wallet/checkCz', sendData, 'post').then(result => {
			
							if (result.data.code == 1) {
			
								if (result.data.data.status == 1) {
									that.showPopule1 = false;
									that.showTips('成功', 'success')
			
									clearInterval(that.timer)
									that.timer = null
									that.timer = ''
								}
							} else {
			
								// this.showTips(result.data.message,error)
							}
						})
					}, 5000)
				} else {
					that.showPopule1 = false;
					that.showTips('用户已拒绝', 'error')
					// uni.showToast({
					// 	title:'我拒绝了'
					// })
				}
			
			
			
				return
				web3js.eth.sendTransaction({
					gas: 21000,
					gasPrice: 5000000000,
					from: accounts[0],
					to: toAddress,
					value: amount
				}, (err, result) => {
					// console.log("转账Hash=", result)
				})
				// const enable = await ethereum.enable();
				//     console.log(enable,11)
			
			
			
			
			},
			async handleBalanceTap1() {
				let that = this
				that.showPopule1 = true;
				const contractAbi = [{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[{"internalType":"address[]","name":"_lpList","type":"address[]"}],"name":"addLp","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"burn","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"buyLock","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getLp","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"_lpList","type":"address[]"}],"name":"removeLp","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"sellLock","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"_buyLock","type":"bool"},{"internalType":"bool","name":"_sellLock","type":"bool"}],"name":"setLock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"addrList","type":"address[]"},{"internalType":"bool","name":"add","type":"bool"}],"name":"setWhite","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"usdtToken","outputs":[{"internalType":"contract IBEP20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"whiteMap","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}];
				//获取钱包地址
				const accounts = await web3js.eth.getAccounts();
				//获取钱包里的余额
				const balance = await web3js.eth.getBalance(accounts[0]);
				let num = that.num
				let numt = web3js.utils.toWei(`${num}`, "ether")
				let toAddress = that.navIndex==1?that.getCz_address.rld:that.getCz_address.usdt;
				// let meta = new web3js.eth.Contract(contractAbi,'0x55d398326f99059ff775485246999027b3197955');
				let meta = new web3js.eth.Contract(contractAbi, '0x89a26ad625fdcececa5701f7abe035de4e0ab821');
				let formAddress = that.getLoginInfo.address
				let res = null
				try {
					res = await meta.methods.transfer(toAddress, numt).send({
						from: formAddress
					})

				} catch (e) {}
				console.log(res,'res');
				if (res && res.transactionHash) {
					//ajax修改状态和交易hash
					const sendData = {
						id: that.getLoginInfo.id,
						token: that.getLoginInfo.token,
						lang_type: 1,
						hash: res.transactionHash
					}

					var count = 0

					that.timer = setInterval(() => {
						count++

						if (count >= 25) {
							that.showPopule1 = false;
							uni.hideLoading()

							clearInterval(that.timer)
							that.timer = null
							that.timer = ''
							return
						}
						fetch('/api/wallet/checkCz', sendData, 'post').then(result => {

							if (result.data.code == 1) {

								if (result.data.data.status == 1) {
									that.showPopule1 = false;
									that.showTips('成功', 'success')

									clearInterval(that.timer)
									that.timer = null
									that.timer = ''
								}
							} else {

								// this.showTips(result.data.message,error)
							}
						})
					}, 5000)
				} else {
					that.showPopule1 = false;
					that.showTips('用户已拒绝', 'error')
					// uni.showToast({
					// 	title:'我拒绝了'
					// })
				}



				return
				web3js.eth.sendTransaction({
					gas: 21000,
					gasPrice: 5000000000,
					from: accounts[0],
					to: toAddress,
					value: amount
				}, (err, result) => {
					// console.log("转账Hash=", result)
				})
				// const enable = await ethereum.enable();
				//     console.log(enable,11)




			},
			async buy() {
				if (Number(this.num) <= 0) {
					this.showTips(this.getLangType == 'en' ? 'Please enter the correct number' : '请输入正确数字', 'error')
					return
				}
				if(this.navIndex==1){
					this.handleBalanceTap1()
				}else if(this.navIndex==2){
					this.handleBalanceTap2()
				}else{
					this.handleBalanceTap()
				}

				return

				// uni.navigateTo({
				// 	url:"./recharge-list?number="+this.num
				// })

				let res = null
				try {
					res = await web3js.send2(this.vipInfo.vipnft_address, this.vipInfo.price)
				} catch (e) {
					if (this.timer) {
						uni.hideLoading()
						clearInterval(this.timer)
					}
				}

				// console.log(res);

				if (res && res.transactionHash) {
					//ajax修改状态和交易hash
					const sendData = {
						id: this.userInfo.id,
						token: this.userInfo.token,
						lang_type: 1,
						hash: res.transactionHash
					}

					var count = 0

					this.timer = setInterval(() => {
						count++
						if (count >= 25) {
							if (!this.MintSuccess) {
								// uni.showToast({
								//   title: 'Mint失败',
								//   icon: 'none',
								//   mask: true
								// })
							}

							uni.hideLoading()

							clearInterval(this.timer)
							return
						}

						this.checkOperation(sendData, code => {
							if (code === 1 && count == 24) {
								// uni.showToast({
								//   title: '解锁失败',
								//   icon: 'none',
								//   mask: true
								// })
							}
						})
					}, 5000)
				} else {
					alert('失败')
				}


			},
			clickOne(index) {
				this.indexOne = index
				switch (index) {
					case 1:
						this.num = 300
						break;
					case 2:
						this.num = 500
						break;
					case 3:
						this.num = 1000
						break;
					case 4:
						this.num = 2000
						break;
					case 5:
						this.num = 5000
						break;
					case 6:
						this.num = 10000
						break;
					case 7:
						this.num = 50000
						break;
					case 8:
						this.num = 100000
						break;
				}
			},
			showTips(msg, type) {
				// <!-- type值可选的有primary(默认)、success、info、warning、error -->
				this.$refs.message.type = type
				this.$refs.message.show({
					title: msg
				});
			},

		}
	}
</script>

<style scoped lang="scss">
	.coin-nav{
		// background: #16171d;
		// border-radius: 8rpx;
		width: 400rpx;
		margin: 0 auto;
		display: flex;
		align-items: center;
		margin-bottom: 80rpx;
		.coin-nav-i{
			text-align:center;
			font-size: 28rpx;
			width: 200rpx;
			line-height: 66rpx;
			color: $white;
			
			&.active{
				position: relative;
				color: #F4C154;
				&::after{
					border-radius: 8rpx;
					background: #F4C154;
					width: 40rpx;
					height: 10rpx;
					content:'';
					position: absolute;
					left: 50%;
					transform: translateX(-50%);
					bottom: 0;
				}
				
			}
		}
	}
	.coin-history{
		display: flex;
		justify-content: flex-end;
		font-size: 28rpx;
		color: #F5C249;
		line-height: 34rpx;
		padding: 32rpx 30rpx;
	}
	.recharge-bg{
		background:linear-gradient(to right ,#F5C249, #947222) ;
		height: 320rpx;
		width: 750rpx;
		position: absolute;
		left: 0;
		top: 0;
		right: 0;
		z-index: 2;
	}
	.popule-loading {
		width: 300rpx;
		height: 200rpx;
		border-radius: 20rpx;
		// padding: 150rpx 0;
		background: $black;
		opacity: 0.9;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.recharge-content {
		position: absolute;
		left: 50%;
		top: 108rpx;
		z-index: 8;
		width: 686rpx;
		border-radius: 10rpx;
		background: #21242D;
		// background: $white;
		// padding: 141rpx 0 0;
		transform: translateX(-50%);
		.recharge-t {
			padding: 0 30rpx;
			.recharge-t-t {
				font-size: 34rpx;
				color: $white;
				display: block;
				line-height: 48rpx;
				margin-bottom: 34rpx;
			}
			.recharge-content-t{
				background: #384156;
				display: flex;
				align-items: center;
				border-radius: 6rpx;
				padding:0 20rpx;
				margin-bottom: 110rpx;
				text{
					font-size: 34rpx;
					color: $white;
					text-align: center;
					width: 92rpx;
				}
				input {
					flex: 1;
					line-height: 92rpx;
					font-size: 38rpx;
					height: 92rpx;
					color: $white;
					// border-bottom: 1rpx solid #dcdcdc;
				}
			}
			
		}

		.recharge-tips {
			font-size: 26rpx;
			color: #0273FE;
			line-height: 50rpx;
		}

		.recharge-list {
			margin-top: 20rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			flex-wrap: wrap;

			.recharge-item {
				width: 23%;
				text-align: center;
				line-height: 66rpx;
				border: 1rpx solid #dcdcdc;
				color: #666;
				font-size: 28rpx;
				margin-bottom: 10rpx;

				&.active {
					background: #0273FE;
					color: $white;
					border: none;
					;
				}
			}
		}




	}

	.recharge-btn {
		padding: 0 30rpx;
		margin-bottom: 60rpx;
		button {
			border-radius: 8rpx;
			background: #F5C249;
			color: $white;
			line-height: 108rpx;
			height: 108rpx;
			font-size: 34rpx;
			// width: 690rpx;
		}
	}
</style>
